package com.walk.zworld.mvvm.vm

import androidx.lifecycle.LiveData
import com.base.lib.httpUtils.ShareResponseBody
import com.walk.zworld.mvvm.repository.ShareRepository
import com.base.lib.base.event.SingleLiveEvent
import com.base.lib.base.mvvm.viewmodel.BaseRefreshViewModel
import com.base.lib.httpUtils.Article

class ShareActivityViewModel : BaseRefreshViewModel<Article>() {

    private val repository = ShareRepository()
    private var data = SingleLiveEvent<Any>()
    private var shareList = SingleLiveEvent<ShareResponseBody>()
    private var delete = SingleLiveEvent<Any>()

    fun shareArticle(map: MutableMap<String, Any>): LiveData<Any> {
        launchUI {
            val res = repository.shareArticle(map)
            data.value = res.data
        }
        return data
    }

    fun getShareList(page: Int): LiveData<ShareResponseBody> {
        launchUI {
            val res = repository.getShareList(page)
            shareList.value = res.data!!
        }
        return shareList
    }

    fun deleteShareArticle(id: Int): LiveData<Any> {
        launchUI {
            val res = repository.deleteShareArticle(id)
            delete.value = res.data
        }
        return delete
    }

    override fun refreshData(params: Any?) {
    }

    override fun loadMore(params: Any?) {
    }
}